#include <cstdio>

bool book[10];
int his[10];
int cnt;

void dfs(int d) {
	if (d>=9) {
		double f = his[0] + (double)his[1]/his[2] + (double)(his[3]*100+
			his[4]*10+his[5]) / (his[6]*100+his[7]*10+his[8]);
		if (f==10) {
			for (int i=0; i<9; i++)
				printf("%d ", his[i]);
			printf("\n");
			cnt++;
		}
		return;
	}
	for (int i=1; i<=9; i++) {
		if (book[i]) continue;
		book[i] = true;
		his[d] = i;
		dfs(d+1);
		book[i] = false;
	}
}

int main() {
	dfs(0);
	printf("\n\nResult:%d\n", cnt);
	return 0;
}
